<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数据类型</title>
    <script>
        function f1(){
            let num = 10;
            console.log(typeof num);
            num = 3.14;
            console.log(typeof num);

            let name = "admin";
            console.log(typeof name);

            let flag = true;
            console.log(typeof flag);
        }

        function f2(){
            // 非正常数据,并不是类型
            let a = null;
            console.log(a)
            console.log(typeof a)
            let b;
            console.log(b)
            console.log(typeof b);
            let c = NaN;
            console.log(c)
            console.log(typeof c);
        }
        function f3(){
            let obj = new Object();
            console.log(typeof obj);

            let arr = [1,3,4];
            console.log(arr)
            console.log(typeof arr);

            let date = new Date();
            console.log(date)
            console.log(typeof date);

            let fn = f4;
            console.log(typeof fn);
            let fn2 = function(){
                console.log("这是一个匿名函数")
            }
            console.log(typeof fn2);

            // 此时的fn3不是函数类型,当出现函数名()的时候表示执行对应的函数
            // 此时表示执行f4函数,并将函数的返回值赋值给对应变量fn3
            // 因此fn3的类型是根据函数返回值类型而定的
            let fn3 = f4();
            console.log(fn3)
            console.log(typeof fn3)
        }

        function f4(){
            console.log("这是一个函数")
            return "admin";
        }
    </script>
</head>
<body>
<button onclick="f1()">基本数据类型</button>
<button onclick="f2()">非正常类型</button>
<button onclick="f3()">复合类型</button>
</body>
</html>